﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;


namespace MyVocationSpace
{
    public partial class AddEditCountry : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString;
            if (!IsPostBack)
            {
                BAL.Industry.PopulateContinent(ref ddlContinent);
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //string val=BAL.Industry.InsertCountry(txtCountry.Text,0);

            int IDcontinent = Convert.ToInt32(ddlContinent.SelectedValue);
            string countryName = txtCountry.Text;

            string val = BAL.Industry.InsertCountry(countryName, IDcontinent);
            if (val != "0")
            {
                idSpanMsg.Style.Add("display", "block");
                idSpanMsg.InnerHtml = "New Country Added Successfully";

                ddlContinent.SelectedValue = "-1";
                txtCountry.Text = "";

            }
            else
            {
                idSpanMsg.Style.Add("display", "block");
                ScriptManager.RegisterStartupScript(this, this.GetType(), "changsCSSClass", "<script type=\"text/javascript\">$('#idSpanMsg').addClass('spanErrorMsgs');</script>", true);
                idSpanMsg.InnerHtml = "Country name already Added";
            }

        }
    }
}